using System;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows;
using SmartBoard.Core.Command;
using SmartBoard.Core.Data;
using SmartBoard.Core.Element;
using SmartBoard.Core.Networking.Client;
using ICommand=SmartBoard.Core.Command.ICommand;

namespace SmartBoard.Ink
{
    public class InkRenderer:InkCanvas,IBoardElement
    {
        private InkRendererCommandBinder _commandBinder;

        public InkRenderer()
        {
            _commandBinder = new InkRendererCommandBinder(this);
        }

        #region DP: IsActive
        public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(
            "IsActive", typeof(bool), typeof(InkRenderer),
            new PropertyMetadata(OnIsActivePropertyChanged));

        private static void OnIsActivePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var instance = (InkRenderer)d;
            var oldValue = e.OldValue ;
            var newValue = (bool)e.NewValue;
            if(newValue)
            {
                instance._commandBinder.Bind();
            }
            else
            {
                instance._commandBinder.Unbind();
            }
        }

        public bool IsActive
        {
            get { return (bool)base.GetValue(IsActiveProperty); }
            set { base.SetValue(IsActiveProperty, value); }
        }

        public IBoardElementStreamManager StreamManager
        {
            get { throw new NotImplementedException(); }
        }

        public IBoardElementDataManager DataManager
        {
            get { throw new NotImplementedException(); }
        }

        public INetworkServiceModule NetworkServiceModule
        {
            get { throw new NotImplementedException(); }
        }

        public IBoardCommandManager CommandManager
        {
            get { throw new NotImplementedException(); }
        }

        public IList<ICommand> BoardCommands
        {
            get { throw new NotImplementedException(); }
        }

        #endregion

        #region IBoardElement Members
        public bool IsInteractiveComponent { get { return true; } }
        public bool IsLocked { get; set; }

        #endregion


    }
}